<?php


namespace app\api\controller;


use app\common\controller\CommonBase;
use app\common\model\Moncar;
use etpcar\EtpCar;

class CarAct extends CommonBase
{
    public function moncaract($info, $type)
    {

        $parkinfo = $this->getparkinfobyid($info['parkid']);
        $option = [
            'key' => $parkinfo['parkkey'],
            'parkno' => $parkinfo['parkno'],
        ];
        $params = [
            'CarNo' => $info['carno'],
            'UserName' => $info['username'],
            'OperType' => $type,
            'Fee' => 0,
            'StartTime' => date('YmdHis', strtotime($info['starttime'])),
            'EndTime' => date('YmdHis', strtotime($info['endtime'])),
            'CarType' => $info['cartype'],
            'CardStatus' => $info['cardstatus'],
            'Balance' => "0",
            'MachList' => $info['lanelist'],
            'SetNo' => $info['setno'],
        ];
        $EptCar = new EtpCar($option);
        $res = $EptCar->up_mon_car($params);
        if ($res) {
            if ($res['ReMsg']['ErrNo'] == "0000") {
                $re_param['return_code'] = "SUCCESS";
                $re_param['return_msg'] = "处理成功";
            } else {
                $re_param['return_code'] = "FAIL";
                $re_param['return_msg'] = $res['ReMsg']['ErrMsg'];
            }
        }else{
            $re_param['return_code'] = "FAIL";
            $re_param['return_msg'] = "回调处理失败";
        }
        return $re_param;
    }
    public function carticketnoact($info,$type){
        $parkinfo = $this->getparkinfobyid($info['parkid']);
        $option = [
            'key' => $parkinfo['parkkey'],
            'parkno' => $parkinfo['parkno'],
        ];
        $params = [
            'OperateType' => $type,
            'CarNo' => $info['carno'],
            'DistType'=> $info['dist_type'],
            'DistFee'=> $info['dist_fee'],
            'StartTime' => date('YmdHis', strtotime($info['starttime'])),
            'EndTime' => date('YmdHis', strtotime($info['endtime'])),
        ];
        $EptCar = new EtpCar($option);
        $res = $EptCar->up_ticket_no($params);
        if ($res) {
            if ($res['ReMsg']['ErrNo'] == "0000") {
                $re_param['return_code'] = "SUCCESS";
                $re_param['return_msg'] = "处理成功";
                $re_param['ticket_no']=$res['ReMsg']['TicketNo'];
            } else {
                $re_param['return_code'] = "FAIL";
                $re_param['return_msg'] = $res['ReMsg']['ErrMsg'];
            }
        }else{
            $re_param['return_code'] = "FAIL";
            $re_param['return_msg'] = "回调处理失败";
        }
        return $re_param;
    }

}